//
//  HZL_StoreDetailTableViewCell.m
//  B_Project
//
//  Created by dllo on 15/11/26.
//  Copyright © 2015年 HZL. All rights reserved.
//

#import "HZL_StoreDetailTableViewCell.h"
#define kScreenWidth  [UIScreen mainScreen].bounds.size.width
@interface HZL_StoreDetailTableViewCell ()<UIWebViewDelegate>
@property (nonatomic, strong) UIWebView *webView;
@end
@implementation HZL_StoreDetailTableViewCell
static int i = 0;
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
   
        //预先加载url
        i++;
        NSLog(@"%d", i);
        if (i == 2) {
            UIWebView *webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, 330, 500)];
            webView.backgroundColor = [UIColor redColor];
            webView.delegate = self;
            [webView loadRequest:[[NSURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://www.molyo.com/mShop/tip/info?shopId=1503231634461344ab043002ade80490&hasTip=1&netWork=wifi"]]];
            [self.contentView addSubview:webView];
        }
     
    }
    return self;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    i = 0;
}

#pragma mark - UIWebView Delegate Methods
-(void)webViewDidFinishLoad:(UIWebView *)webView
{
    //获取到webview的高度
    CGFloat height = [[self.webView stringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight"] floatValue];
    self.webView.frame = CGRectMake(self.webView.frame.origin.x,self.webView.frame.origin.y, kScreenWidth, height);
}
- (void)webViewDidStartLoad:(UIWebView *)webView
{
    NSLog(@"webViewDidStartLoad");
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(nullable NSError *)error
{
    NSLog(@"didFailLoadWithError===%@", error);
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
